﻿// See https://aka.ms/new-console-template for more information
using PacketDotNet;
using SharpPcap;
using WebMiddleware.Utils;
using System.Linq;

internal class Program
{
    private static void Main(string[] args)
    {
        using TcpStreamListenner listenner = new TcpStreamListenner();

        Console.Write("Src Port: ");
        var srcPort = int.Parse(Console.ReadLine());

        Console.Write("Dst Port: ");
        var dstPort = int.Parse(Console.ReadLine());


        var devices = CaptureDeviceList.Instance;

        for (int index = 0; index < devices.Count; index++)
        {
            Console.WriteLine(index + " " + devices[index].Description);
        }
        Console.Write("Please select your network device：");
        var selectedIndex = int.Parse(Console.ReadLine());

        //listenner.Open(port, "Intel(R) Ethernet Connection (10) I219-V");        
        listenner.Open($"(tcp and src port {srcPort} and dst port {dstPort}) or (tcp and src port {dstPort} and dst port {srcPort})", devices[selectedIndex].Description);

        Console.WriteLine("按任意键停止捕获...");
        Console.ReadKey();

        listenner.Close();
    }
}